import cv2
import mss
import numpy as np

def grab_screen(position_grab):
    with mss.mss() as sct:
        # 获取窗口区域
        window = sct.grab(position_grab)
        window = np.array(window)
        # 转换图片
        window_2rgb = cv2.cvtColor(window, cv2.COLOR_BGR2RGB)
        window_rgb = window_2rgb[:, :, ::-1]
        return window_rgb
